﻿<phone:PhoneApplicationPage 
    x:Class="XMPPClient.ChatPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">

<phone:PhoneApplicationPage.Resources>
	    <Style x:Key="ListBoxStyle1" TargetType="ListBox">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBox">
                            <Grid x:Name="LayoutRoot">
                                <Border Padding="5" BorderBrush="#000000" BorderThickness="1" Background="#ffffff" CornerRadius="0">
                                    <ScrollViewer x:Name="ScrollViewer" VerticalScrollBarVisibility="Hidden" Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}" BorderBrush="Transparent" BorderThickness="0">
                                        <ItemsPresenter />
                                    </ScrollViewer>
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
	    <Style x:Key="RichTextBoxStyle1" TargetType="RichTextBox">
	    	<Setter Property="FontSize" Value="{StaticResource PhoneFontSizeNormal}"/>
	    	<Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
	    	<Setter Property="Background" Value="Transparent"/>
	    	<Setter Property="BorderBrush" Value="Transparent"/>
	    	<Setter Property="BorderThickness" Value="0"/>
	    	<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
	    	<Setter Property="VerticalContentAlignment" Value="Center"/>
	    	<Setter Property="Padding" Value="0"/>
	    	<Setter Property="Template">
	    		<Setter.Value>
	    			<ControlTemplate TargetType="RichTextBox">
	    				<Grid Background="Transparent">
	    					<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="{TemplateBinding Margin}">
	    						<ContentControl x:Name="ContentElement" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
	    					</Border>
	    				</Grid>
	    			</ControlTemplate>
	    		</Setter.Value>
	    	</Setter>
	    </Style>
	</phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="340*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="150"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Rectangle Stroke="{Binding Presence.PresenceBrush}" Fill="{x:Null}" Margin="4" Grid.Column="0" Grid.Row="0" />
        <Image Grid.Column="0" Grid.Row="0" Margin="8" Source="{Binding Avatar}"/>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Column="1">
            <StackPanel Orientation="Horizontal">
                <!--<TextBlock x:Name="ApplicationTitle" Text="Conversation" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock Text="-" />-->
                <TextBlock Text="" x:Name="TextBlockConversationTitle" Style="{StaticResource PhoneTextNormalStyle}"/>
            </StackPanel>
            <Button x:Name="ButtonStartVoice" Click="ButtonStartVoice_Click">Start Voice Call</Button>
            <MediaElement x:Name="AudioStream" Stretch="Uniform" />
            <StackPanel Orientation="Horizontal">
                <Button x:Name="ButtonPreviousResource" Click="ButtonPreviousResource_Click_1">&lt;</Button>
                <TextBlock x:Name="TextBlockResource" Width="220" VerticalAlignment="Center" TextAlignment="Center" Style="{StaticResource PhoneTextNormalStyle}">priority</TextBlock>
                <Button x:Name="ButtonNextResource" Click="ButtonNextResource_Click_1">&gt;</Button>
            </StackPanel>
        </StackPanel>


        <ScrollViewer Background="Black"  x:Name="ScrollChat" Margin="5,0" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" VerticalScrollBarVisibility="Visible" >
            <RichTextBox Background="Black" IsReadOnly="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" VerticalContentAlignment="Top" 
                         VerticalScrollBarVisibility="Visible" ScrollViewer.VerticalScrollBarVisibility="Visible"  AcceptsReturn="True"
                         x:Name="TextBlockChat" ScrollViewer.HorizontalScrollBarVisibility="Visible" Foreground="Black" 
                         Margin="5,5,5,10" Padding="0" Style="{StaticResource RichTextBoxStyle1}" />
        </ScrollViewer>
        <!--<ListBox Grid.Row="1" Style="{StaticResource ListBoxStyle1}" VerticalAlignment="Stretch" 
                 DataContext="{Binding Conversation}"
                 Background="Beige" x:Name="ListBoxConversation" Grid.ColumnSpan="2">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock FontSize="10" Text="{Binding Path=From.User}" Foreground="Gray"  />
                            <TextBlock FontSize="10" Text="{Binding Received}" Foreground="Gray" />
                        </StackPanel>
                        <TextBlock Text="{Binding Message}" Foreground="{Binding TextColor}" TextWrapping="Wrap"  />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>-->
        

        <TextBox Grid.Row="2" x:Name="TextBoxChatToSend" InputScope="Chat"  KeyDown="TextBoxChatToSend_KeyDown" Grid.ColumnSpan="2"></TextBox>
        
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IsEnabled="True" IconUri="Images/chat.png" Text="Send Text" x:Name="ButtonSendMessage" Click="ButtonSendMessage_Click"/>
            <shell:ApplicationBarIconButton IsEnabled="True" IconUri="Images/trash.png" Text="Clear" x:Name="ButtonClearMessages" Click="ButtonClearMessages_Click"/>
            <shell:ApplicationBarIconButton IsEnabled="True" IconUri="Images/camera.png" Text="Send Photo" x:Name="ButtonSendPhoto" Click="ButtonSendPhoto_Click"/>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>
